package engine.systems.spatial.spatialOffset
{
	import engine.classes.enumerations.SystemPriority;
	import engine.systems.update.GameSystem;
	
	public class SpatialOffsetSystem extends GameSystem
	{
		private var offset:SpatialOffset;
		private var data:SpatialOffsetData;
		
		public function SpatialOffsetSystem()
		{
			super(SpatialOffsetNode, updateNode);
			
			this.priority = SystemPriority.SPATIAL_OFFSET;
		}
		
		private function updateNode(node:SpatialOffsetNode, time:Number):void
		{
			offset = node.offset;
			
			offset._x 			= 0;
			offset._y 			= 0;
			offset._rotation 	= 0;
			offset._scaleX 		= 0;
			offset._scaleY 		= 0;
			
			for each(data in offset._data)
			{
				offset._x 			+= data.x;
				offset._y 			+= data.y;
				offset._rotation 	+= data.rotation;
				offset._scaleX 		+= data.scaleX;
				offset._scaleY 		+= data.scaleY;
			}
		}
	}
}